//
//  NSString+HXMD5.m
//  ZCooking
//
//  Created by 韩旭 on 16/9/24.
//  Copyright © 2016年 HX_. All rights reserved.
//

#import "NSString+HXMD5.h"
#import <CommonCrypto/CommonCrypto.h>
@implementation NSString (HXMD5)
- (NSString *)stringWithhx_MD5_32Bitmd_5Lower {
    return [[self stringWith32_Bit] lowercaseString];
}
- (NSString *)stringWith32_Bit {
    //   1. 将字符串转化成c语言
    const char *cString = [self UTF8String];
    //   2 将c的字符串转化_MD5
    CC_LONG lenth = (CC_LONG)strlen(cString);
    unsigned char bytes[CC_MD5_DIGEST_LENGTH];
    CC_MD5(cString, lenth, bytes);
    //    3. 将C 字符串转化成OC的字符串
    NSMutableString *finalString = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
    for (int i = 0; i < CC_MD5_DIGEST_LENGTH; i ++) {
        [finalString appendFormat:@"%02x", bytes[i]];
    }
    return finalString;
}
@end
